<template>
  <el-dialog v-model="dialogVisible" title="添加关联设备 POS机SN号" center>
    <el-input v-model="textarea" resize="none" :rows="2" type="textarea" placeholder="请输入设备 POS机SN号，多个用“,”隔开" />
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="savePOS">
          保存
        </el-button>
      </span>
    </template>
  </el-dialog>
</template>
<script setup>
import { nextTick, ref } from 'vue';
import { isEmpty } from 'lodash-es';
import { ElMessage } from 'element-plus';
const textarea = ref('');
const dialogVisible = ref(false)

const emit = defineEmits(['savePOSVal'])

const savePOS = () => {
  if(!isEmpty(textarea.value)){
    dialogVisible.value = false;
    emit('savePOSVal',textarea.value.trim())
    nextTick(()=>{
      textarea.value = '';
    })
  }else{
    ElMessage.error('请输入设备 POS机SN号')
  }
}


defineExpose({
  dialogVisible,
  textarea
})
</script>
<style lang="less" scoped></style>